package utiles.net
{
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import game.define.ProtocolDefine;
	
	[Event(name="throw_msg", type="utiles.net.VirtualServerEvent")]
	
	public class VirtualServer extends EventDispatcher
	{
		public function VirtualServer(target:IEventDispatcher=null)
		{
			super(target);
		}
		
		public function recv(protocol:QProtocol):void
		{
			switch (protocol.type)
			{
				case ProtocolDefine.USER_INFO_REQ:
					onUserInfoReq(protocol);
					break;
			}
		}
		
		private function send(msg:QProtocol):void
		{
			var event:VirtualServerEvent = new VirtualServerEvent(VirtualServerEvent.THROW_MSG);
			event.msg = msg;
			dispatchEvent(event);
		}
		
		///CMD
		private function onUserInfoReq(msg:QProtocol):void
		{
			var protocol:QProtocol = new QProtocol();
			protocol.type = ProtocolDefine.USER_INFO_RESP;
			protocol.body = {
				sceneID:1
			};
			send(protocol);
		}
	}
}